package com.fas.system.enums;

import com.fas.common.utils.StringUtils;

public enum TemplateEnum {

    /** 设备模板 */
    EQUIPMENT(1,"equipmentTemplate.xlsx","设备信息模板.xlsx"),
    /** 设施模板 */
    FACILITIES(2,"facilitiesTemplate.xlsx","设施信息模板.xlsx"),
    /** 建筑模板 */
    BUILDING(3,"buildingTemplate.xlsx","建筑公司模板.xlsx");


    private Integer value;
    private String fileName;
    private String zhName;

    TemplateEnum(Integer value ,String fileName,String zhName) {
        this.value = value;
        this.fileName = fileName;
        this.zhName = zhName;
    }

    /**
     * 通过name取描述
     * @param value
     * @return
     */
    public static String[] getNameByValue(Integer value) {
        if (value == null){
            return null;
        }
        for (TemplateEnum enums : TemplateEnum.values()) {
            if (value.equals(enums.getValue())) {
                String[] strings = new String[2];
                strings[0] = enums.getFileName();
                strings[1] = enums.getZhName();
                return strings;
            }
        }
        return null;
    }
    /**
     * 通过value取枚举
     * @param fileName
     * @return
     */
    public static TemplateEnum getTypeByValue(String fileName){
        if (StringUtils.isNull(fileName)){
            return null;
        }
        int valueKey = Integer.parseInt(fileName);
        for (TemplateEnum enums : TemplateEnum.values()) {
            if (enums.getValue() == valueKey) {
                return enums;
            }
        }
        return null;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getZhName() {
        return zhName;
    }

    public void setZhName(String zhName) {
        this.zhName = zhName;
    }
}
